package com.iflytek.application.common.springdata.jdbc.repository;

import com.iflytek.application.common.springdata.jdbc.repository.support.MysqlJdbcTemplateRepository;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * Created by franky on 2016/9/13.
 */
public class JdbcTemplateFactory implements  JdbcTemplateRepository{
    private JdbcTemplate jdbcTemplate;
    public JdbcTemplateFactory(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
   private String DBTYPE="mysql";
    @Override
    public int save(String tablename, Object object) throws Exception {
        if(DBTYPE.equals("mysql")){
            return new MysqlJdbcTemplateRepository(jdbcTemplate).save(tablename,object);
        }
        return 0;
    }

    @Override
    public int update(String tablename, String properties, Object object) throws Exception {
        return 0;
    }

    @Override
    public List<?> saveOrUpdateAll(String tablename, String keyid, Object object, List<?> list) throws Exception {
        return null;
    }

    @Override
    public Object findOne(Class<?> c, String table, int id) {
        return null;
    }

    @Override
    public Object findOne(Class<?> c, String sql) throws Exception {
        return null;
    }

    @Override
    public Object findAll(Class<?> c, String sql) throws Exception {
        return null;
    }

    @Override
    public Object findAll(Class<?> c, String sql, Object[] params) throws DataAccessException {
        return null;
    }
}
